package com.model;

import cn.hutool.core.util.RandomUtil;
import com.baima46.annotion.ExcelHeader;
import com.baima46.annotion.ExcelHeaderCol;
import com.baima46.annotion.ExcelParent;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description 程序员类
 * @Author yuan cong
 * @Date 2020/12/7 0007
 */
//@ExcelParent(2) //coder继承person,导出excel也会导出person中使用了 @ExcelHeader 的字段，默认父类字段在前，可通过@ExcelParent()注解指定排列位置：0：不继承父类属性， 1：在最前方(默认)，2：在最后方
@Data
public class Coder extends Person{
    @ExcelHeader({"职位级别", "职位级别"})
    private String position;
    @ExcelHeader({"代码行数(万)", "代码行数(万)"})
    private int codeNum;
    @ExcelHeader({"薪水（k）", "薪水（k）"})
    private int salary;

    @ExcelHeaderCol
    private List<CoderStat> coderStats;




    public Coder() {
        position = "P" + RandomUtil.randomInt(1, 9);
        codeNum = RandomUtil.randomInt(1, 1000);
        salary = codeNum/10 + RandomUtil.randomInt(0, 5);
    }

    /**
     * 生成导出的数据
     * @param num
     * @return
     */
    public static List<Coder> getCoder(int num) {
        List<Coder> list = new ArrayList<>(num);
        for (int j = 0; j < num; j++) {
            list.add(new Coder());
        }

        return list;
    }
    /**
     * 生成导出的数据
     * @param num
     * @return
     */
    public static List<Coder> getCoder2(int num) {
        List<Coder> list = new ArrayList<>(num);
        for (int j = 0; j < num; j++) {
            Coder coder = new Coder();
            coder.setCoderStats(CoderStat.getCoderStat(5));
            list.add(coder);
        }

        return list;
    }
}
